package com.model.dome1;

import com.model.domin.Student;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class HashMapWork {
    public static void main(String[] args) {
        Map<Student,String> map = new HashMap<>();

        Student s1 = new Student("张三",20);
        Student s2 = new Student("李四",22);
        Student s3 = new Student("王五",21);

        map.put(s1,"湖南");
        map.put(s2,"湖北");
        map.put(s3,"浙江");

        Set<Map.Entry<Student, String>> entries = map.entrySet();
        for (Map.Entry<Student, String> entry : entries) {
            Student key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key+"----"+value);
        }

        System.out.println("==================");

        Set<Student> student = map.keySet();
        for (Student key : student) {
            String value = map.get(key);
            System.out.println(key+"----"+value);
        }

    }
}
